import os
from pathlib import Path

import pytest

from .ets import ets_files


@pytest.fixture()
def filelist(tmp_path: Path):
    filelist = tmp_path / 'filelist'
    with filelist.open('w') as fp:
        for file in ets_files():
            fp.write(f'{file!s}\n')
    return filelist


@pytest.fixture()
def build_dir():
    panda_build_dir = os.getenv(
        key='PANDA_BUILD_DIR',
        default='~/projects/panda/current/build',
    )
    path = Path(panda_build_dir).expanduser().resolve()
    assert path.is_dir()
    assert (path / 'bin' / 'es2panda').exists()
    return path
